package com.amlyc.java并发编程之美.ch01;

public class ThreadLocalTest {
    static ThreadLocal<String> localVariable = new ThreadLocal<String>();
    static void print(String str){
        System.out.println(str+":"+localVariable.get());
    }

    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                localVariable.set("threadone");
                print("one");
                localVariable.remove();
            }
        }).start();
        new Thread(()->{
            localVariable.set("threadtwo");
            print("two");
            localVariable.remove();
        }).start();
    }
}
